package com.smasher.component.activity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;

import androidx.core.content.ContextCompat;

import com.smasher.component.databinding.ActivitySpinnerBinding;
import com.smasher.stepview.StepPanel;
import com.smasher.stepview.entity.StepBean;
import com.smasher.widget.base.BaseActivity;

import java.util.ArrayList;
import java.util.List;

public class WidgetActivity extends BaseActivity {

    private ActivitySpinnerBinding mBinding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    /**
     * 进行获取根部的View
     *
     * @return RootView
     */
    @Override
    public View getRootView() {
        mBinding = ActivitySpinnerBinding.inflate(getLayoutInflater());
        return mBinding.getRoot();
    }

    /**
     * 进行初始化相关的View
     */
    @Override
    public void initView() {
        // mBinding.stepView.setStepViewTexts(mBinding.stepView.getStepViewTexts())
        List<StepBean> stepsBeanList = new ArrayList<>();
        stepsBeanList.add(new StepBean("已完成", StepBean.STEP_COMPLETED));
        stepsBeanList.add(new StepBean("已完成", StepBean.STEP_COMPLETED));
        stepsBeanList.add(new StepBean("进行中", StepBean.STEP_CURRENT));
        stepsBeanList.add(new StepBean("未开始", StepBean.STEP_UNDO));
        mBinding.stepView
                .setStepViewComplectedTextColor(getResources().getColor(android.R.color.holo_blue_dark))
                .setStepViewUnComplectedTextColor(getResources().getColor(android.R.color.holo_green_light))
                .setStepViewTexts(stepsBeanList);

        mBinding.timeLine.setStep(2);
        mBinding.timeLine.setOnStepChangedListener((view, step, stepStr) ->
                Log.i("StepLineView", "onChanged: step=" + step + " stepStr=" + stepStr));

        mBinding.stepPanel.setPaneListener(new StepPanel.PanelListener() {
            @Override
            public void onPageChanged(int current) {

            }

            @Override
            public void onSubmit(int current) {
                Log.i("StepPanel", "onSubmit: ");
            }

            @Override
            public boolean onNext(int current, int target) {
                Log.i("StepPanel", "onNext: current = " + current + " target = " + target);
                return true;
            }

            @Override
            public boolean onPrevious(int current, int target) {
                Log.i("StepPanel", "onPrevious: current = " + current + " target = " + target);
                return true;
            }
        });

        mBinding.stepPrevious.setOnClickListener(v -> mBinding.timeLine.previousStep());

        mBinding.stepNext.setOnClickListener(v -> mBinding.timeLine.nextStep());

        ArrayList<String> sss = new ArrayList<>();
        sss.add("fdsjklfjdks");
        sss.add("fdjisofjeiwo");
        sss.add("jiklfdjksl");
        sss.add("lkjkljkl");
        mBinding.verticalOnly.setStepViewComplectedTextColor(ContextCompat.getColor(this, com.smasher.widget.R.color.color_838A96));
        mBinding.verticalOnly.setStepViewUnComplectedTextColor(ContextCompat.getColor(this, com.smasher.widget.R.color.color_3B3F47));
        mBinding.verticalOnly.setStepViewTexts(sss);
    }

    /**
     * 进行初始化相关的数据
     */
    @Override
    public void initData() {

    }


}